﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SanQiOther.Models;
namespace SanQiOther.Controllers
{
    public class BusStaController : Controller
    {
        private RewardDbContext db = new RewardDbContext();
        // GET: BusSta
        public ActionResult Index()
        {
            List<SelectListItem> items = new List<SelectListItem>();
            items.Add(new SelectListItem { Text = "2019", Value = "2019" });
            items.Add(new SelectListItem { Text = "2020", Value = "2020" });
            this.ViewData["YearList"] = items;

            List<SelectListItem> itemss = new List<SelectListItem>();
            itemss.Add(new SelectListItem { Text = "1", Value = "1" });
            itemss.Add(new SelectListItem { Text = "2", Value = "2" });
            itemss.Add(new SelectListItem { Text = "3", Value = "3" });
            itemss.Add(new SelectListItem { Text = "4", Value = "4" });
            itemss.Add(new SelectListItem { Text = "5", Value = "5" });
            itemss.Add(new SelectListItem { Text = "6", Value = "6" });
            itemss.Add(new SelectListItem { Text = "7", Value = "7" });
            itemss.Add(new SelectListItem { Text = "8", Value = "8" });
            itemss.Add(new SelectListItem { Text = "9", Value = "9" });
            itemss.Add(new SelectListItem { Text = "10", Value = "10" });
            itemss.Add(new SelectListItem { Text = "11", Value = "11" });
            itemss.Add(new SelectListItem { Text = "12", Value = "12" });
            this.ViewData["MonthList"] = itemss;

            ViewBag.Year = 0;
            ViewBag.Month = 0;
            return View();
        }


        [HttpPost]
        public ActionResult Index(FormCollection form)
        {

            int year = Convert.ToInt16(form["YearList"]);
            int month = Convert.ToInt16(form["MonthList"]);

            List<SelectListItem> items = new List<SelectListItem>();         
            items.Add(new SelectListItem { Text = "2019", Value = "2020" });
            this.ViewData["YearList"] = items;
            List<SelectListItem> itemss = new List<SelectListItem>();
            itemss.Add(new SelectListItem { Text = "1", Value = "1" });
            itemss.Add(new SelectListItem { Text = "2", Value = "2" });
            itemss.Add(new SelectListItem { Text = "3", Value = "3" });
            itemss.Add(new SelectListItem { Text = "4", Value = "4" });
            itemss.Add(new SelectListItem { Text = "5", Value = "5" });
            itemss.Add(new SelectListItem { Text = "6", Value = "6" });
            itemss.Add(new SelectListItem { Text = "7", Value = "7" });
            itemss.Add(new SelectListItem { Text = "8", Value = "8" });
            itemss.Add(new SelectListItem { Text = "9", Value = "9" });
            itemss.Add(new SelectListItem { Text = "10", Value = "10" });
            itemss.Add(new SelectListItem { Text = "11", Value = "11" });
            itemss.Add(new SelectListItem { Text = "12", Value = "12" });
            this.ViewData["MonthList"] = itemss;


            ViewBag.Year = year;
            ViewBag.Month = month;

            return View();
        }


        public ActionResult Index_1(int Year, int Month)
        {

            var car_mail = db.car_main.Where(r => r.year == Year && r.month == Month);

            return View(car_mail.ToList());
        }

        public ActionResult Index_2(int Year, int Month)
        {

            var v_car_detail = db.v_car_detail.Where(r => r.year == Year && r.month == Month && r.car == 1).OrderBy(r => r.deptmc).ThenBy(r => r.isls).ThenBy(r => r.islz);

            return View(v_car_detail.ToList());
        }

        public ActionResult Index_3(int Year, int Month)
        {

            var v_car_detail = db.v_car_detail.Where(r => r.year == Year && r.month == Month && r.car == 2).OrderBy(r => r.deptmc).ThenBy(r => r.isls).ThenBy(r => r.islz);

            return View(v_car_detail.ToList());
        }

        public ActionResult Index_4(int Year, int Month)
        {

            var v_car_detail = db.v_car_detail.Where(r => r.year == Year && r.month == Month && r.car == 3).OrderBy(r => r.deptmc).ThenBy(r => r.isls).ThenBy(r => r.islz);

            return View(v_car_detail.ToList());
        }
        public ActionResult Index_5(int Year, int Month)
        {

            var v_car_detail = db.v_car_detail.Where(r => r.year == Year && r.month == Month && r.car == 4).OrderBy(r => r.deptmc).ThenBy(r => r.isls).ThenBy(r => r.islz);

            return View(v_car_detail.ToList());
        }
        public ActionResult Index_6(int Year, int Month)
        {

            var v_car_detail = db.v_car_detail.Where(r => r.year == Year && r.month == Month && r.car == 5).OrderBy(r => r.deptmc).ThenBy(r => r.isls).ThenBy(r => r.islz);

            return View(v_car_detail.ToList());
        }

    }
}